var loginModule = angular.module("loginModule", []);
loginModule.controller("loginCtrl", ['$scope',
    function ($scope) {
        function init() {
            Metronic.init(); // init metronic core components
            Layout.init(); // init current layout
            Login.init();
            Demo.init();
            //// init background slide images
            $.backstretch([
                    "lib/metronic/assets/admin/pages/media/bg/2.jpg",
                    "lib/metronic/assets/admin/pages/media/bg/3.jpg"
                ], {
                    fade: 1000,
                    duration: 8000
                }
            );

            $scope.loginParam = {
                name: "",
                pwd: ""
            }
        }

        $scope.login = function () {
            if ($('.login-form').validate().form()) {
                $post($scope.basePath + "/rest/operator/login", $scope.loginParam, function (result) {
                    $scope.$cookieStore.put("TOKEN", result.resultValue.token);
                    $scope.$cookieStore.put("OPERATOR", result.resultValue.operator);
                    $scope.$state.go("home.content.merchant.merchantList")
                })
            }
        }
        init();
    }
]);